package com.zyy.study.JUC;

import org.junit.Test;

import java.util.concurrent.*;

public class ExecutorDemo {
    @Test
    public void testCallable() throws ExecutionException, InterruptedException {
        FutureTask<Integer> integerFutureTask = new FutureTask<>(new callableTask());
        Thread thread = new Thread(integerFutureTask);
        thread.start();
        System.out.println(integerFutureTask.get());
        Future<Integer> submit = Executors.newSingleThreadExecutor().submit(new callableTask());
    }
}

class callableTask implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        return 1;
    }
}
